<?php
/**
 * @author jonathan poelen <jonathan.poelen@gmail.com>
 * @version 1.0: jo_link_noir
 * @date 27-05-2010
 */
class SW_Structure_Element extends SW_Element_Group
{
	/** @var int|null*/
	protected $duration;

	/** @var array*/
	protected $price;

	/** @var int*/
	protected $level;

	/** @var int|null*/
	protected $timeEnd;


	/**
	 * @param int $id
	 * @param int $group
	 * @param int $level = 0
	 * @param int $duration = null
	 * @param array $price = null
	 * @param int $time_end = null
	 */
	public function __construct($id, $group, $level=0, $duration = null, array $price = null, $time_end = null)
	{
		parent::__construct($id, $group);
		$this->level = (int)$level;
		$this->duration = ($duration === null) ? null : (int)$duration;
		$this->price = $price;
		$this->timeEnd = ($time_end === null) ? null : (int)$time_end;
	}

	/**
	 * Augmente le niveau level
	 * @param int $level = 1
	 */
	public function increase($level = 1)
	{
		$this->level += (int)$level;
	}

	/**
	 * @return int|null
	 */
	public function getTimeEnd()
	{
		return $this->timeEnd;
	}

	/**
	 * @return int|null
	 */
	public function getDuration()
	{
		return $this->duration;
	}

	/**
	 * @return int
	 */
	public function getLevel()
	{
		return $this->level;
	}

	/**
	 * @return array
	 */
	public function getPrice()
	{
		return $this->price;
	}

	/**
	 * @param int $time_end
	 */
	public function setTimeEnd($time_end)
	{
		$this->timeEnd = $time_end;
	}

	/**
	 * @param int $duration
	 */
	public function setDuration($duration)
	{
		$this->duration = $duration;
	}

	/**
	 * @param int $level
	 */
	public function setLevel($level)
	{
		$this->level = $level;
	}

	/**
	 * @param array $price
	 */
	public function setPrice(array $price)
	{
		$this->price = $price;
	}
}